<?php
include("include/conn.php");
require('include/Smarty/libs/Smarty.class.php');

$billbook = array();
$selectParty = "SELECT billbook.billBookId,billbook.partyId,billbook.billNo,billbook.prevFine,
                       DATE_FORMAT(billbook.billBookDate,'%d-%m-%Y') AS billBookDate,
                       DATE_FORMAT(billbook.billBookDate,'%m') AS curDateMonth,
                       DATE_FORMAT(billbook.billBookDate,'%Y') AS curDateYear,
                       billbook.prevAmount, party.partyId,party.partyName,billbook.totalFine,billbook.totalAmount 
                  FROM billbook
                  JOIN party ON party.partyId = billbook.partyId
                 ORDER BY billbook.billBookDate DESC, billbook.billNo DESC";
$selectPartyRes = mysql_query($selectParty);
$a = 0;
while($partyRow = mysql_fetch_assoc($selectPartyRes))
{
  $billbook[$a]['billBookId']   = $partyRow['billBookId'];
  $billbook[$a]['billNo']       = $partyRow['billNo'];
  $billbook[$a]['partyId']      = $partyRow['partyId'];
  $billbook[$a]['partyName']    = $partyRow['partyName'];
  $billbook[$a]['billBookDate'] = $partyRow['billBookDate'];
  $billbook[$a]['curDateMonth'] = $partyRow['curDateMonth'];
  $billbook[$a]['curDateYear']  = $partyRow['curDateYear'];
  $billbook[$a]['totalFine']    = $partyRow['totalFine'];
  $billbook[$a]['totalAmount']  = $partyRow['totalAmount'];
  $a++;
}

$smarty = new Smarty;

require("bottom.php");
$smarty->assign("l_date",$l_date);
$smarty->assign("l_party",$l_party);
$smarty->assign("l_billBookDate",$l_billBookDate);
$smarty->assign("l_edit",$l_edit);
$smarty->assign("l_delete",$l_delete);
$smarty->assign("l_billBookDetailId",$l_billBookDetailId);

$smarty->assign("billbook",$billbook);

$smarty->display("billBookList.tpl");
?>